<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
  <head>
    <title>消费级别</title>
  </head>
  <body>
    <div id="costLevelsGrid" style="height:580px;" class="x-form-item">
    </div>
    <script>
        /*
         * Ext JS Library 2.0.2
         * Copyright(c) 2006-2008, Ext JS, LLC.
         * licensing@extjs.com
         *
         * http://extjs.com/license
         */
        Ext.onReady(function(){
            var costLevelCM = new Ext.grid.ColumnModel([new Ext.grid.RowNumberer(), {
                    header: '编号',
                    dataIndex: 'id'
                }, {
                    header: '消费级别',
                    dataIndex: 'cost_level'
                }, {
                    header: '消费金额',
                    dataIndex: 'consumption'
                }, {
                    header: '备注',
                    dataIndex: 'remark'
                }]);
            //隐藏系统编号
            costLevelCM.setHidden(1, !costLevelCM.isHidden(1));
            var costLevelDS = new Ext.data.Store({
                proxy: new Ext.data.HttpProxy({
                    url: '/admin/getAllCostLevels'
                }),
                reader: new Ext.data.JsonReader({
                    totalProperty: 'totalProperty',
                    root: 'root'
                }, [{
                        name: 'id'
                    }, {
                        name: 'cost_level'
                    }, {
                        name: 'consumption'
                    }, {
                        name: 'remark'
                    }])
            });
            /************************************************************
             * Define menubar now in here
             *   add and delete functions
             ************************************************************/
            var menubar = [{
                    text: '增加消费级别',
                    tooltip: '增加消费级别',
                    iconCls: 'addItem',
                    handler: function(){
                        // add new costlevel now - action
                        CreateCostLevel(costLevelDS);
                    }
                }, '-', {
                    text: '删除消费级别',
                    tooltip: '删除消费级别',
                    iconCls: 'remove',
                    handler: function(){
                        // delete costlevel now - action
                        DeleteCostLevel(costLevelDS, costLevelGridPanel);
                    }
                }, '-', {
                    text: '编辑消费级别',
                    tooltip: '编辑消费级别',
                    iconCls: 'editItem',
                    handler: function(){
                        // delete costlevel now - action
                        EditCostLevel(costLevelDS, costLevelGridPanel);
                    }
                }];
            var costLevelGridPanel = new Ext.grid.GridPanel({
                el: 'costLevelsGrid',
                ds: costLevelDS,
                cm: costLevelCM,
                //sm: sm,
                collapsible: true,
                animCollapse: false,
                title:'消费级别列表',
                tbar: menubar,
                loadMask: true
            });
            costLevelGridPanel.render();
            //ds.load();
            costLevelDS.load();
                
        });
        
    </script>
  </body>
</html>
